<?php

namespace App\Http\Controllers\Baidu;

use Illuminate\Http\Request;
use	Exception;

include_once ('../app/libary/Baidu/CommonService.php');

use Signer;

use CommonService;

use App\Http\Controllers\Baidu\ReportController;

class LiveReportController extends CommonService
{
    var $request;


    public function __construct()
    {
        parent::__construct ( 'sms', 'service', 'LiveReportService' );
    }

    public function getAccountLiveData (){

        $this->request = ['dataType'=>1,'device'=>0];

        $data =  $this->execute ( 'getAccountLiveData',$this->request);
        return response()->json($data);
    }


    /**
     * @return \Illuminate\Http\JsonResponse
     * 关键词实时数据
     */
    public function getKeywordLiveData (){

        $report = new  ReportController();
        $result = $report->getRealTimeData();
        $result = json_decode($result);
        $ids = [];
        foreach ($result->body->data as $value)
        {
            $ids[] .= $value->id;
        }

        $this->request['keywordIds'] = $ids;      //  关键词数组
        $this->request['regionTarget'] = [1000];     //  地区数组
        $this->request['device'] = 0;

        $data =  $this->execute ( 'getKeywordLiveData',$this->request);
        return response()->json($data);


    }


}
